<script setup >
import { ref } from "vue";
import axios from "axios";
import { ElNotification } from 'element-plus';

let phonenum = ref({
        "phonenum": "",
        "passwordnum": ""
})

const onSubmit =()=>{
  axios.post("http://127.0.0.1:8000/user/phone/login/",{"phone1":phonenum.value.phonenum,"password1":phonenum.value.passwordnum}).then(res=>{
    console.log(res)
    console.log(phonenum.value)
    if(res.data.msg == "登陆成功"){
      ElNotification({
      title: '登陆成功',
      message: 'This is a success message',
      type: 'success',
  })
    }
    else{
      ElNotification({
      title: '登陆失败',
      message: 'This is a success message',
      type: 'success',
  })
      
    }
  })
}

const unSubmit=()=>{
  phonenum.value = {
        "phone": "",
        "password": ""
}
}

</script>

<template>

<el-form :model="phonenum" label-width="auto" style="max-width: 600px">
    <el-form-item label="Activity phone">
      <el-input v-model="phonenum.phonenum" />
    </el-form-item>
    <el-form-item label="Activity password">
      <el-input v-model="phonenum.passwordnum" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">login</el-button>
      <el-button @click="unSubmit">cancel</el-button>
    </el-form-item>
  </el-form>

</template>

<style >



</style>
